<?php

/**
 * @name: HOTN AnimeList
 * @author: HammerOnTheNail
 * @link: http://code.google.com/p/hotnanimelist/
 */

// Admin oldal címének meghatározása
$title .= " \ ".HOTN_ANIMELIST_ADMIN_MENU_PROJECT_DELETE;
$text = "";

// POST
if ($_POST['action'] == "delete")
{
	$project_id = (int)$_POST['project_id'];
	
	$HOTN_ANIMELIST_DOWNLOAD->hotn_animelist_download_delete_all_file($project_id);
	$sql->db_Delete("hotn_animelist_project","project_id = '".$project_id."'");
	$ns -> tablerender(HOTN_ANIMELIST_ADMIN_DEFAULT_ERROR_TITLE, HOTN_ANIMELIST_ADMIN_PROJECT_DELETE);
}

// Választó kiírása
$sql->db_Select("hotn_animelist_project", "project_id, project_name, project_mode, project_type","ORDER BY project_type, project_name ASC","");
while ($row = $sql->db_Fetch())
{
	
	if ($row['project_type'] == "anime") $row['project_type'] = HOTN_ANIMELIST_DEFAULT_ANIME;
	if ($row['project_type'] == "manga") $row['project_type'] = HOTN_ANIMELIST_DEFAULT_MANGA;
	
	if ($row['project_mode'] == "finished")
	{
		$project_finished[$row['project_id']] = $row['project_name']." (".$row['project_type'].")";
	}
	if ($row['project_mode'] == "active")
	{
		$project_active[$row['project_id']] = $row['project_name']." (".$row['project_type'].")";
	}
	if ($row['project_mode'] == "dropped")
	{
		$project_dropped[$row['project_id']] = $row['project_name']." (".$row['project_type'].")";
	}
	if ($row['project_mode'] == "passive")
	{
		$project_passive[$row['project_id']] = $row['project_name']." (".$row['project_type'].")";
	}
	if ($row['project_mode'] == "planned")
	{
		$project_planned[$row['project_id']] = $row['project_name']." (".$row['project_type'].")";
	}
}

$project = array(
	HOTN_ANIMELIST_ANIMETYPE_ACTIVE => $project_active,
	HOTN_ANIMELIST_ANIMETYPE_FINISHED => $project_finished,
	HOTN_ANIMELIST_ANIMETYPE_PLANNED => $project_planned,
	HOTN_ANIMELIST_ANIMETYPE_PASSIVE => $project_passive,
	HOTN_ANIMELIST_ANIMETYPE_DROPPED => $project_dropped
); 

$data = array(
	"method" => "post",
	"action" => e_SELF."?project.delete",
	"hidden" => array(
				"action" => "delete",
			),
	"data" => array(
				array(
					"type" => "select",
					"name" => "project_id",
					"group" => "true",
					"text" => HOTN_ANIMELIST_ADMIN_PROJECT_PROJECT_NAME,
					"value" => $project
				),
				array(
					"type" => "submit",
					"value" => HOTN_ANIMELIST_DEFAULT_FORM_DELETE
				)
			)
);

// Admin oldal tartalmának megjelenítése
$text .= "<div style='text-align: center;'>".$HOTN_ANIMELIST_FORM->show_form($data)."</div>";
?>